package com.ys.service.flow;

import java.util.List;
import java.util.Map;

import com.ys.entity.flow.YspDefLink;
import com.ys.entity.flow.YspDefNode;
import com.ys.entity.flow.YspTask;
import com.ys.entity.flow.YspTaskAudit;
import com.ys.entity.sys.YsProcInst;
import com.ys.vo.Flow;
import com.ys.vo.R;

import lombok.AllArgsConstructor;
import lombok.Data;

public interface YspTaskService {
	
	R init(String codeModel, String bid, String createUserId) throws Exception;
	
	Flow flowPass(String bid, String loginUserId) throws Exception;
	
	R flowDelete(String bid, String loginUserId) throws Exception;
	
	FinalNodeDto findFinalNode(YsProcInst ysProcInst, YspTask yspTask, YspTaskAudit yspTaskAuditCurrent,String loginUserId);
	@Data
	@AllArgsConstructor
	public class FinalNodeDto{
		private boolean flag; // 结果标志，true有找到，false没有找到
		private YspDefNode node; // 下一个节点
		private List<PathDto> paths; // 经历的路径数组
		@Data
		@AllArgsConstructor
		public static class PathDto{
			private YspDefNode nodeFrom; // 开始节点
			private YspDefNode nodeTo; // 结束节点
			private YspDefLink link; // 连接线
		}
	}

	
	NodeToDto findNodeTo(YsProcInst ysProcInst, YspTask yspTask, YspDefNode yspDefNodeCurrent,String loginUserId);
	@Data
	@AllArgsConstructor
	public class NodeToDto{
		private YspDefNode node; // 经历的节点
		private YspDefLink link; // 经历的连接线
	}
	
	List<String> findAuditorOfNode(YspDefNode yspDefLinkNext, String codeUserCurrent, String bid) throws Exception;
	
	R flowRefuse(String bid, String reason, String loginUserId) throws Exception;
	
	R flowInit(String bid, String reason, String loginUserId) throws Exception;
	
	void addFlowPath(Long taskId, Long taskAuditId, Integer type, List<FinalNodeDto.PathDto> paths);
	
	/**
	 * 流程状态，0制单1流转中2已完成，null未知
	 * @param bid
	 * @return
	 */
	Integer flowState(String bid);

	Map<String, Object> getNextTaskAuditUser(String loginUserId,String bid)throws Exception;


	//修改审批流整单其他特殊参数信息
	R setOtherParams(String bid, Object remark, Object companyName) throws Exception;

}